package com.evaluation_system.mapper;

import com.evaluation_system.pojo.DTO.UploaderPageQueryDTO;
import com.evaluation_system.pojo.entity.Uploader;
import com.evaluation_system.pojo.entity.saveFileInfo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UploaderMapper {
    @Select("SELECT id FROM uploader WHERE username = #{username}")
    Integer getId(String username);

    @Insert("INSERT INTO file(uploader_id,summary,file_path,file_name,secret_key,secret_iv) VALUES (#{uploaderId},#{summary},#{filePath},#{fileName},#{secretKey},#{secretIV})")
    void insertFile(saveFileInfo saveFileInfo);


    Page<Uploader> pageQuery(UploaderPageQueryDTO uploaderPageQueryDTO);

    @Insert("INSERT INTO uploader(username,password,truth) VALUES (#{username},#{password},#{truth})")
    void insert(Uploader uploader);

    void update(Uploader uploader);

    @Delete("DELETE FROM uploader WHERE id = #{id}")
    void deleteById(Integer id);
}
